// @ts-ignore
/* eslint-disable */
import { request } from '@umijs/max';

/** 查询当前用户地址列表 GET /addresses */
export async function findMyAddresses(options?: { [key: string]: any }) {
  return request<API.Address[]>('/addresses', {
    method: 'GET',
    ...(options || {}),
  });
}

/** 新增地址 POST /addresses */
export async function save(body: API.Address, options?: { [key: string]: any }) {
  return request<any>('/addresses', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}

/** 根据id查询地址 GET /addresses/${param0} */
export async function findAddressById(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: API.findAddressByIdParams,
  options?: { [key: string]: any },
) {
  const { addressId: param0, ...queryParams } = params;
  return request<API.Address>(`/addresses/${param0}`, {
    method: 'GET',
    params: { ...queryParams },
    ...(options || {}),
  });
}

/** 设置为默认地址 PUT /addresses/default */
export async function setDefaultAddress(options?: { [key: string]: any }) {
  return request<any>('/addresses/default', {
    method: 'PUT',
    ...(options || {}),
  });
}

/** 根据id删除地址 DELETE /addresses/delete */
export async function deleteAddressById(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: API.deleteAddressByIdParams,
  options?: { [key: string]: any },
) {
  return request<any>('/addresses/delete', {
    method: 'DELETE',
    params: {
      ...params,
    },
    ...(options || {}),
  });
}

/** 更细地址 PUT /addresses/update */
export async function updateAddress(body: API.Address, options?: { [key: string]: any }) {
  return request<any>('/addresses/update', {
    method: 'PUT',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}
